class Weekly < WeeklyConnect
  has_many :weekly_results, :dependent => :destroy
  belongs_to :last, :foreign_key => :parent_id, :class_name => 'Weekly'

  def self.latest
      find :first, :conditions => "wid is not null", :order => '"index" desc' 
  end

  def check_zero_results
    all :conditions => "(clicks = 0 or clicks is null) and (comments = 0 or comments is null)
and (danmu = 0 or danmu is null) and (stows = 0 or stows is null)"
  end

  def check_and_update_zero
    rs = check_zero_results
    WeeklyConnect.transaction do
      check_zero_results.each do |r|

      end
    end
  end

  def to_mylist
    http = Net::HTTP.start(BILI_PATH)
    http.post "/plus/stow.php", "aid=#{wid}&ajax	=1&dopost=save&lid=791&stow_target=mylist", 'Cookie' => COOK
  end
end
